#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again.  This script gets executed directly, so it could be python, php,
# ruby, etc.
set -x
if [ ! -d $OPENSHIFT_DATA_DIR/jdk1.8.0_20 ]
	then 
		cd $OPENSHIFT_DATA_DIR
		wget http://www.java.net/download/jdk8u20/archive/b17/binaries/jdk-8u20-ea-bin-b17-linux-x64-04_jun_2014.tar.gz
		tar xvf *.tar.gz 
		rm -f *.tar.gz
fi

if [ ! -d $OPENSHIFT_DATA_DIR/apache-maven-3.3.9 ]
	then 
		cd $OPENSHIFT_DATA_DIR
		wget http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
		tar xvf *.tar.gz 
		rm -f *.tar.gz
fi

export M2=$OPENSHIFT_DATA_DIR/apache-maven-3.3.9/bin
export JAVA_HOME=$OPENSHIFT_DATA_DIR/jdk1.8.0_20
export PATH=$JAVA_HOME/bin:$M2:$PATH

cd $OPENSHIFT_REPO_DIR
mvn -s $OPENSHIFT_REPO_DIR/.openshift/settings.xml -q clean install
